import { Group } from '@/components/pro-panel/index.typing';
import { useNormalColumns } from './normal-columns';
import { useWaterColumns } from './water-columns';

/**
 * 常规区域面分组
 */
export const normalGroups: Group[] = [
  {
    key: 'basic',
    title: '基础设置',
    collapsed: false,
  },
  {
    key: 'fillEffect',
    title: '填充效果',
    collapsed: false,
  },
  {
    key: 'borderEffect',
    title: '边框效果',
    collapsed: false,
  },
];

export const normalFormData = {
  enable: true,
  name: '',
  type: 'polygon', // 类型
  dataSourceUrl: '',
  createType: '',
  specularMapExtent: [119.835748667, 31.875664929, 120.021156344, 32.03150772], // 范围(围成矩形)
  // specularMap: '../dist/map_src/changzhou/wgs84/wccz/water/wcwatermask.png', // 遮罩(决定水体的形状)
  layerType: 1,
  heightKey: '',
  heightValue: 0,
  extrudedHeightKey: '',
  extrudedHeightFeild: '',
  extrudedHeightValue: 0,
  fillTab: '颜色',
  borderTab: '颜色',
  fillColor: '#FF5454',
  alpha: 1,
};

/**
 * 水体分组
 */
export const waterGroups: Group[] = [
  {
    key: 'basic',
    title: '基础设置',
    collapsed: false,
  },
  {
    key: 'fillEffect',
    title: '效果配置',
    collapsed: false,
  },
];

/**
 * 水体初始化数据
 */
export const waterFormData = {
  name: '',
  type: 'water', // 类型
  specularMapExtent: [119.835748667, 31.875664929, 120.021156344, 32.03150772], // 范围(围成矩形)
  // specularMap: '../dist/map_src/changzhou/wgs84/wccz/water/wcwatermask.png', // 遮罩(决定水体的形状)
  layerType: 2,
  heightKey: '',
  heightValue: 0,
  // extrudedHeightKey: '',
  // extrudedHeightFeild: '',
  // extrudedHeightValue: 0,
  // tabValue: '颜色',
  // fillColor: '#FF5454',
  // alpha: 1,
  baseWaterColor: '#FF4027', // 基本颜色
  blendColor: '#FFFFFF', // 叠加颜色
  cubeMap: {
    negativeX: 'http://192.168.50.85:15055/image/skybox/noon/left.png',
    positiveX: 'http://192.168.50.85:15055/image/skybox/noon/right.png',
    negativeY: 'http://192.168.50.85:15055/image/skybox/noon/front.png',
    positiveY: 'http://192.168.50.85:15055/image/skybox/noon/back.png',
    negativeZ: 'http://192.168.50.85:15055/image/skybox/noon/down.png',
    positiveZ: 'http://192.168.50.85:15055/image/skybox/noon/top.png',
  }, // 环境贴图
  normalMapUrl: 'http://192.168.50.85:15055/image/water/waterNormals_new.jpg', //法向图
  alpha: 1, // 透明度
  frequency: 10, // 波纹数量 默认10
  animationSpeed: 1, // 动画速度/水流速度(默认0.003)
  angle: 0, // 水流方向
  amplitude: 1, // 1,  振动幅度
  u_frequency: 1000, //650,UV缩放：
  v_frequency: 1000, //200,
  specularIntensity: 0.5, //反射度
  refractIntensity: 0, //折射度
};

export function usePanelConfig() {
  const layerType = ref(2);
  const formData = ref<any>({
    fillTab: '贴图',
    borderTab: '贴图',
  });

  const groups = computed(() => {
    if (layerType.value === 1) {
      return normalGroups;
    } else if (layerType.value === 2) {
      return waterGroups;
    } else {
      return waterGroups;
    }
  });

  const changeLayerType = (value: number) => {
    layerType.value = value;
  };

  /**
   * 常规区域面
   */
  const { normalColumns } = useNormalColumns(formData.value, changeLayerType);

  const { waterColumns } = useWaterColumns(changeLayerType);

  const columns = computed(() => {
    if (layerType.value === 1) {
      return normalColumns.value;
    } else if (layerType.value === 2) {
      return waterColumns.value;
    } else {
      return waterColumns.value;
    }
  });

  return {
    groups,
    columns,
    formData,
  };
}
